﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace LearnDrive
{
    public partial class Tbutton : UserControl
    {

        //定义委托
        public delegate void BtnClickHandle(object sender, EventArgs e);
        //定义事件
        public event BtnClickHandle UserControlBtnClicked;
        
        private Color bgcolor;
        private string num;
        private string daan;
        private Color daancolor;
        private int whsize = 38;

        public int Whsize
        {
            get { return whsize; }
            set { whsize = value;
            this.Width = this.Height = whsize;
            panel1.Width = panel1.Height = whsize;
            }
        }
        public Color Daancolor
        {
            get { return daancolor; }
            set { daancolor = value;
            label2.ForeColor = daancolor;
            //label1.ForeColor = daancolor;
            }
        }
        public string Daan
        {
            get { return label2.Text; }
            set { daan = value;
            label2.Text = daan;
            }
        }
        public string Num
        {
            get { return num; }
            set { num = value;
            label1.Text = num;
            }
        }
        public Color Bgcolor
        {
            get { return bgcolor; }
            set { bgcolor = value;
            panel1.BackColor = bgcolor;
            }
        }
        public Tbutton()
        {
            InitializeComponent();
        }

        private void Tbutton_Load(object sender, EventArgs e)
        {

        }

        private void Tbutton_Click(object sender, EventArgs e)
        {
            if (UserControlBtnClicked != null)
                UserControlBtnClicked(this, new EventArgs());//把按钮自身作为参数传递
        }

        private void panel1_Click(object sender, EventArgs e)
        {
            if (UserControlBtnClicked != null)
                UserControlBtnClicked(this, new EventArgs());//把按钮自身作为参数传递

        }
    }
}
